<template>
  <div>
    <router-link to="/equipment/AddEquipment"><el-button>添加</el-button></router-link>
    <el-table
      :data="equipmentList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="name"
        label="设备名">
      </el-table-column>
      <el-table-column
        prop="price"
        label="价格">
      </el-table-column>
      <el-table-column
        prop="createDate"
        label="创建时间">
      </el-table-column>
      <el-table-column
        prop="description"
        label="描述">
      </el-table-column>

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button @click="deleteById(scope.row.id)" size="mini">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <router-view/>
  </div>
</template>

<script>
    export default {
        name: "equipmentList",
      data(){
          return {
            equipmentList:[],
            equipment:{}
          }
      },
      created(){
        this.selectAll();
      },
      methods:{
        deleteById(id){
          this.axios.delete("/equipment/delete/"+id).then((resp)=>{
            //提示保存成功信息
            this.$message.success("删除成功！");
            this.selectAll();
          });
        },
        selectAll(){
          //发出ajax请求请求后端代码
          let url="/equipment/selectAll";
          this.axios.get(url).then((resp)=>{
            this.equipmentList=resp.data;
          });
        }
      }
    }
</script>

<style scoped>

</style>
